<div>
    <div>
        <button nz-button nzType="primary" (click)="add()">+ 新增</button>
        <a nz-button nzType="default" (click)="edit()">修改</a>
        <button nz-button nzType="primary" style="float: right">导入科室设置数据</button>
    </div>
    <nz-table #basicTable [nzData]="departmentList" nzSize="small" class="medical-table">
        <thead>
            <tr>
                <th nzWidth="50px"></th>
                <th>科室编码</th>
                <th>科室名称</th>
                <th>科室类别</th>
                <th>记录状态</th>
                <th>操作员</th>
                <th>更新日期</th>
                <th>备注</th>
            </tr>
        </thead>
        <tbody>
            <tr *ngFor="let data of basicTable.data" [ngClass]="{'selectedRow':selectedRowData.id === data.id}" (click)="selectedRow(data)">
                <td style="background: #fff;"><span class="checkbox" [ngClass]="{active:selectedRowData.id === data.id}"><i nz-icon nzType="check" nzTheme="outline"></i></span></td>
                <td>{{ data.id }}</td>
                <td>{{ data.departmentName }}</td>
                <td>
                    <div style="width: 120px;" class="editable-cell" *ngIf="!editTable; else editType">
                        {{ departmentTypes[data.departmentTypeId] }}
                    </div>
                    <ng-template #editType>
                        <nz-select style="width: 120px;" [(ngModel)]="data.departmentTypeId">
                            <nz-option [nzValue]="item.id" [nzLabel]="item.name" *ngFor="let item of departmentTypesList"></nz-option>
                        </nz-select>
                    </ng-template>
                </td>
                <td>
                    <div style="width: 120px;" class="editable-cell" *ngIf="!editTable; else editStatus">
                        {{ data.status === "Y" ? "正常" : "停用" }}
                    </div>
                    <ng-template #editStatus>
                        <nz-select style="width: 120px;" [(ngModel)]="data.status">
                            <nz-option nzValue="Y" nzLabel="正常"></nz-option>
                            <nz-option nzValue="N" nzLabel="停用"></nz-option>
                        </nz-select>
                    </ng-template>
                </td>
                <td>{{ data.operaterId }}</td>
                <td>{{ data.editTime }}</td>
                <td>{{ data.memo }}</td>
            </tr>
        </tbody>
    </nz-table>
    <nz-modal [(nzVisible)]="isVisible" nzTitle="新增科室" (nzOnCancel)="handleCancel()" (nzOnOk)="handleOk()">
        <form nz-form [formGroup]="validateForm">
            <nz-form-item>
                <nz-form-label [nzSm]="6" [nzXs]="24" nzRequired nzFor="departmentName">科室名称</nz-form-label>
                <nz-form-control [nzSm]="14" [nzXs]="24" [(nzValidateStatus)]="validateForm.controls.departmentName">
                    <input nz-input formControlName="departmentName" id="departmentName" placeholder="请输入科室名称" />
                    <nz-form-explain *ngIf="validateForm.get('departmentName')?.dirty && validateForm.get('departmentName')?.errors">科室名称不能为空！</nz-form-explain>
                </nz-form-control>
            </nz-form-item>
            <nz-form-item>
                <nz-form-label [nzSm]="6" [nzXs]="24" nzFor="departmentTypeId" nzRequired>科室类别</nz-form-label>
                <nz-form-control [nzSm]="14" [nzXs]="24" [nzValidateStatus]="validateForm.get('departmentTypeId')">
                    <nz-select formControlName="departmentTypeId">
                        <nz-option [nzValue]="item.id" [nzLabel]="item.name" *ngFor="let item of departmentTypesList"></nz-option>
                    </nz-select>
                    <nz-form-explain *ngIf="validateForm.get('departmentTypeId')?.dirty && validateForm.get('departmentTypeId')?.errors">科室类别不能为空！</nz-form-explain>
                </nz-form-control>
            </nz-form-item>
            <nz-form-item>
                <nz-form-label [nzSm]="6" [nzXs]="24" nzFor="memo">备注</nz-form-label>
                <nz-form-control [nzSm]="14" [nzXs]="24" [(nzValidateStatus)]="validateForm.controls.memo">
                    <textarea rows="2" nz-input formControlName="memo" id="memo" placeholder="请输入..."></textarea>
                </nz-form-control>
            </nz-form-item>
        </form>
    </nz-modal>
</div>
